#ifndef SALE_H_
#define SALE_H_

#include "Transaction.h"
#include <sstream>

class Sale: public Transaction {
public:
	Sale() {
		/*stringstream ss;
		last_SaleID++;
		ss<<"TS";
		ss << (int) last_SaleID;
		saleID=ss.str();*/
	}
	Sale(Item _item,Date _date, string _starterID, string _enderID):Transaction(_date, _starterID, _enderID), item(_item) {
		stringstream ss;
		last_SaleID++;
		ss << "TS";
		ss << (int) last_SaleID;
		saleID = ss.str();
	}
	Sale(Item _item,Date _date, string _starterID, string _enderID, bool _isEnded): Transaction(_date, _starterID, _enderID, _isEnded),item(_item) {
		stringstream ss;
		last_SaleID++;
		ss << "TS";
		ss << (int) last_SaleID;
		saleID = ss.str();
	}
	virtual ~Sale() {}

	/** @return ID of sale */
	string getID() const { return saleID; }

	/** @return item of sale */
	Item getItem() const { return item;}

	/** sets items of sale equal to _items */
	void setItemsOwner(vector<Item> & _items) { item.setOwner(_items[0].getOwner()); }

	/** Adds the sale's data to the records filename */
	void save(string filename, ofstream & out);

	/** Shows the information about the sale */
	void showTransaction();

	/** @return vector<Item> containing item */
	vector<Item> getItems() const {
		vector<Item> v;
		v.push_back(item);
		return v;
	}

private:
	string saleID;
	static unsigned int last_SaleID;
	Item item;
};

#endif /* SALE_H_ */
